<template>
  <div class="school">
    <h2>学校名称：{{ name }}</h2>
    <h2>学校地址：{{ address }}</h2>
  </div>
</template>

<script>
  export default {
    name: "School",
    props: ['getSchoolName'],
    data() {
      return {
        name: "尚硅谷",
        address: "北京昌平",
      };
    },
    mounted() {
      // console.log(window.x);
      // console.log('School', this.x.$on, this.$on);
      this.$bus.$on('hello', (data) => {
        console.log('我是School组件，收到了数据', data);
      })
    },
    beforeDestroy() {
      // 傀儡总线上面有许多事件 当vc销毁 需要解绑特定的事件 减少性能消耗
      this.$bus.$off('hello')
    }
  };
</script>

<style scoped>
  .school {
    background-color: rgb(14, 158, 91);
    padding: 5px;
  }
</style>